<template>
  <div class="detail">
    <detail-news other="aaaa" :info="detail"></detail-news>
  </div>
</template>

<script>
import axios from "axios";
import { Indicator } from "mint-ui";
import { Toast } from "mint-ui";
import DetailNews from "../components/DetailNews";

const SUCCESS_OK = "200";
export default {
  components: {
    "detail-news": DetailNews
  },
  data() {
    return {
      detail: {}
    };
  },
  beforeCreate() {
    Indicator.open({
      text: "加载中...",
      spinnerType: "fading-circle"
    });
  },
  created() {
    axios({
      method: "post",
      url: "http://111.204.164.42/news/findNewsByNewsId.do",
      params: this.$route.params
    })
      .then(res => {
        res = res.data;
        if (res.code === SUCCESS_OK) {
          this.detail = res.news;
          // console.dir(this.detail);
          Indicator.close();
        } else {
          Indicator.close();
          let instance = Toast({
            message: "加载失败"
          });
          setTimeout(() => {
            instance.close();
          }, 2000);
        }
      })
      .catch(error => {
        console.warn(error);
      });
  }
};
</script>
